package com.ywgt.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ywgt.pojo.User;
import com.ywgt.mapper.UserMapper;
import com.ywgt.pojo.UserInfo;
import com.ywgt.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author yiping
 * @since 2021-03-13
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public Page<User> getUsers(String username, String mobile, int page, int limit, String sort, String order) {
        PageHelper.startPage(page,limit);
        Page<User> users=baseMapper.selectUses(username,mobile,sort,order);
        return users;
    }

    @Override
    public UserInfo getUserInfo(Integer userId) {
        UserInfo userInfo=new UserInfo();
        User user = this.getById(userId);
        userInfo.setAvatar(user.getAvatar());
        userInfo.setNickname(user.getNickname());
        return userInfo;
    }
}
